#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)  
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

int _,n,p,a[100005],sum[100005],flag[100005],last,ans;

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> _;
    while(_--){
        cin >> n >> p;
        last = 0 , ans = 0;
        rep(i,1,n) cin >> a[i];
        rep(i,1,n) sum[i] = sum[i-1] + a[i] % p , sum[i] %= p;
        rep(i,0,p) flag[i] = -1;  flag[0] = 0;
        rep(i,1,n){
            if(flag[ sum[i] ] >= last) ++ans , last = i;
            flag[ sum[i] ] = i;
        }
        cout << ans << '\n';
    }
    return 0;
}